<template>
  <el-dialog
    :visible="dialogVisible"
    width="400px"
    title="创建还原任务"
    @close="$emit('close')"
  >
    <el-form
      ref="form"
      label-width="130px"
      :model="form"
      :rules="rules"
    >

      <el-form-item
        label="ID"
        prop="backupTaskId"
      >
        <el-input
          v-model="form.backupTaskId"
          placeholder=""
          disabled
        />
      </el-form-item>

      <el-form-item
        label="任务名"
        prop="taskName"
      >
        <el-input
          v-model="form.taskName"
          placeholder=""
          clearable
        />
      </el-form-item>

      <el-form-item
        label="库名"
        prop="dbName"
      >
        <el-input
          v-model="form.dbName"
          placeholder=""
          clearable
        />
      </el-form-item>

      <el-form-item
        label="还原模式"
        prop="restoreModel"
      >
        <el-select
          v-model="form.restoreModel"
          style="width:100%"
        >
          <el-option
            label="表级"
            value="table"
          />
          <el-option
            label="库级"
            value="database"
          />
        </el-select>
      </el-form-item>

      <el-form-item
        label="标识"
        prop="flag"
      >
        <el-input
          v-model="form.flag"
          disabled
        />
      </el-form-item>
      
      <el-form-item
        label="还原时间节点"
        prop="restoreTimeNode"
      >
        <el-input
          v-model="form.restoreTimeNode"
          clearable
        />
      </el-form-item>

    </el-form>

    <div
      slot="footer"
      class="dialog-footer"
    >
      <el-button
        @click="$emit('close')"
      >取 消</el-button>
      <el-button
        type="primary"
        @click="addUatBlackList"
      >确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import cbApi from '@/api/coldStandby/index'

const form = {
  backupTaskId: '',
  taskName: '',
  dbName: '',
  restoreModel: 'table',
  flag: '',
  restoreTimeNode: ''
}
export default {
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    backupTaskId: String,
    flag: String
  },
  data() {
    return {
      form: {...form}
    }
  },
  computed: {
    rules() {
      return {
        taskName: [
          { required: true, message: '请输入任务名', trigger: 'blur' }
        ],
        dbName: [
          { required: true, message: '请输入库名', trigger: 'blur' }
        ],
        restoreModel: [
          { required: true, message: '请选择还原模式', trigger: 'blur' }
        ],
        restoreTimeNode: [
          { required: true, message: '请输入时间还原节点', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {
    dialogVisible(val) {
      if (!val) {
        this.form = {...form}
      } else {
        this.form.backupTaskId = this.backupTaskId
        this.form.flag = this.flag
      }
    }
  },
  methods: {
    addUatBlackList() {
     
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
